<template>
  <div class="dashboard-editor-container">
    <!-- <pre v-highlightjs="sourcecode"><code class="javascript">
    </code></pre> -->
    <highlightjs language="cpp" :code="code" />
  </div>
</template>

<script>
import hljs from "highlight.js/lib/common"; // 使用该导入，样式即生效
import "highlight.js/styles/dark.css"; // 引入内置样式
export default {
  data() {
    return {
      code: `void getTimeFromServer()
{
        String timeurl = "https://www.baidu.com";
        HTTPClient http;
        http.begin(timeurl);
        const char *headerKeys[] = {"Date"};
        http.collectHeaders(headerKeys, sizeof(headerKeys) / sizeof(headerKeys[0]));
        int httpCode = http.GET();
        Date = http.header("Date");
        Serial.println(Date);
        http.end();
}      `
    };
  }
};
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}

::v-deep pre {
  .hljs {
    text-indent: 2px;
    line-height: 20px;
    color: #abb0b6;
    .hljs-function {
      .hljs-type {
        color: #d19957 !important;
      }
      .hljs-title {
        color: #61aeee !important;
      }
    }
    .hljs-string {
      color: #98c379 !important;
    }
    .hljs-built_in {
      color: #e6be76 !important;
    }
    .hljs-type {
      color: #d1995c !important;
    }
    .hljs-number {
      color: #d19552 !important;
    }
  }
}
</style>
